﻿using Microsoft.Extensions.DependencyInjection;
using Modules.BankSpecialAccount.Entitys;
using Modules.BankSpecialAccount.Repositories;
using Pipelines.Sockets.Unofficial.Arenas;
using PmSoft;
using PmSoft.Exceptions;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Modules.BankSpecialAccount;

/// <summary>
/// 专户累计进账、线上和线下代发金额统计每月统计服务
/// </summary>
[UseDI(ServiceLifetime.Scoped)]
public class BankSpecialAccountStatisticMonthService
{
    private readonly BankSpecialAccountStatisticMonthRepository projectSpecialAccountStatisticMonthRepository;

    public BankSpecialAccountStatisticMonthService(BankSpecialAccountStatisticMonthRepository projectSpecialAccountStatisticMonthRepository)
    {
        this.projectSpecialAccountStatisticMonthRepository = projectSpecialAccountStatisticMonthRepository;
    }

    /// <summary>
    /// 专户累计进账、线上和线下代发金额统计每月统计表单详情
    /// </summary>
    /// <param name="id">主键</param>
    /// <returns></returns>
    public BankSpecialAccountStatisticMonth? Get(int id)
    {
        return projectSpecialAccountStatisticMonthRepository.Get(id);
    }

    /// <summary>
    /// 批量删除，根据id
    /// </summary>
    /// <param name="ids">id的集合</param>
    public void Deleted(IEnumerable<int> ids)
    {
        foreach (int id in ids)
        {
            Delete(id);
        }
    }

    /// <summary>
    /// 单个删除
    /// </summary>
    /// <param name="id">主键</param>
    public void Delete(int id)
    {
        projectSpecialAccountStatisticMonthRepository.DeleteByEntityId(id);
    }

    /// <summary>
    /// 创建专户累计进账、线上和线下代发金额统计每月统计
    /// </summary>
    /// <param name="entity">实体对象</param>
    public void Create(BankSpecialAccountStatisticMonth entity)
    {
        projectSpecialAccountStatisticMonthRepository.Insert(entity);
    }

    /// <summary>
    /// 编辑专户累计进账、线上和线下代发金额统计每月统计
    /// </summary>
    /// <param name="entity">实体对象</param>
    public void Update(BankSpecialAccountStatisticMonth entity)
    {
        projectSpecialAccountStatisticMonthRepository.Update(entity);
    }

    /// <summary>
    /// 通过银行专户账号获取统计信息
    /// </summary>
    /// <param name="account"></param>
    /// <returns></returns>
    public BankSpecialAccountStatisticMonth? GetProjectSpecialAccountStatisticMonthByBankAccountMonth(string account, int month)
    {
        return projectSpecialAccountStatisticMonthRepository.GetProjectSpecialAccountStatisticMonthByBankAccountMonth(account, month);
    }
}